#include <bits/stdc++.h>
using namespace std;
#define int long long

int q;

namespace CR200J {
	multiset<pair<int, int>> s;
	pair<int, int> chk(pair<int, int> i, pair<int, int> j) {
		if (i == j) return {i.second - i.first + 1, i.second - i.first + 1};
		if (i.first > j.first) swap(i, j);
		/*
		   [   ] -> i
		      [   ] -> j
		*/
		return {
			max(i.second - j.first + 1, 0ll), j.second - i.first + 1};
	}
	void main() {
		while (q--) {
			string op;
			int l, r;
			cin >> op >> l >> r;
			--r;
			if (l <= r) {
				if (op == "A") s.insert({l, r});
				else s.erase(s.find({l, r}));
			} else assert(0); 
			pair<int, int> ans = {1ll << 60, 1ll << 60};
			for (auto i : s) {
				for (auto j : s) {
					ans = min(ans, chk(i, j));
				}
			}
			cout << ans.second << "\n";
		}
	}
}

namespace BF5033 {
	multiset<pair<int, int>> s;	pair<int, int> chk(pair<int, int> i, pair<int, int> j) {
		if (i == j) return {i.second - i.first + 1, i.second - i.first + 1};
		if (i.first > j.first) swap(i, j);
		/*
		   [   ] -> i
		      [   ] -> j
		*/
		return {
			max(i.second - j.first + 1, 0ll), j.second - i.first + 1};
	}
	multiset<pair<int, int>> anss;
	void ins(pair<int, int> a, pair<int, int> b) {
		anss.insert(chk(a, b));
	}
	void ers(pair<int, int> a, pair<int, int> b) {
		anss.erase(anss.find(chk(a, b)));
	}
	void main() {
		while (q--) {
			string op;
			int l, r;
			cin >> op >> l >> r;
			--r;
			if (l <= r) {
				const auto it = s.lower_bound({l, r});
				if (op == "A") {
					ins({l, r}, {l, r});
					if (it != s.end()) {
						ins({l, r}, *it);
					}
					if (it != s.begin()){
						ins({l, r}, *prev(it));
					}
					if (it != s.end() && it != s.begin()) {
						ers(*it, *prev(it));
					}
					s.insert({l, r});
				} else {
					ers({l, r}, {l, r});
					if (next(it) != s.end()) {
						ers({l, r}, *next(it));
					}
					if (it != s.begin()){
						ers({l, r}, *prev(it));
					}
					if (next(it) != s.end()&&it != s.begin()) {
						ins(*prev(it), *next(it));
					}
					s.erase({l, r});
				}
			} 
			cout << anss.begin() -> second << "\n";
		}
	}
}

signed main() {
	freopen("stone.in", "r", stdin); freopen("stone.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> q;
	if (q <= 500) {
		CR200J::main();
	} else BF5033::main();
	return 0;
}
